﻿<!DOCTYPE html>
<html>

<head>
    <title>THCView.DoSectionDrawItemPaintAfter(THCCustomData,Integer,TRect,Integer,Integer,Integer,Integer,TCanvas,TPaintInfo) Method</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="generator" content="Documentation Insight" />
    <base target="_self" />
    <link type="text/css" rel="Stylesheet" href="css/presentation.css" />
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.cookie.js"></script>
    <script type="text/javascript" src="js/di.js"></script>
    <style type="text/css">
        .tabHead {
            float: left;
            padding-left: 2px;
        }

        .active {
            background-color: #f8f8f8;
        }

        .disActive {
            background-color: #939393;
            border-bottom: solid 1px #939393;
        }

        .tabHead :hover {
            background-color: bisque;
            cursor: pointer;
        }

        .unActive {
            display: none;
        }

        p.hcNor {
            line-height: 1.5;
        }

    </style>
    <script type="text/javascript" src="js/jquery-migrate.min.js"></script>
    <!--[if (!IE) | (gt IE 8)]><!-->
    <link type='text/css' rel='Stylesheet' href='css/highlighter.css' />
    <!--<![endif]-->
    <!--[if (!IE) | (gt IE 8)]><!-->
    <script src="js/highlight.min.js"></script>
    <!--<![endif]-->
    <script type="text/javascript">
        if (($.browser.msie == undefined) || ($.browser.version > 8)) {
            hljs.tabReplace = '  ';
            $(document).ready(function() {
                $("#footerContent").html(getCopyright());

                $('pre').each(function(i, e) {
                    hljs.highlightBlock(e);
                });
            });
        }

    </script>
    <script type="text/javascript">
        if (top.frames.length == 0) {
            var topicUrl = top.location.href.substring(top.location.href.lastIndexOf("/") + 1, top.location.href.length);
            var regex = new RegExp('(mk:@MSITStore|ms-help):?', 'i')
            if (!top.location.href.match(regex)) {
                top.location.href = "index.htm?" + topicUrl;
            }
        } else if (top && top.navigationFrame && top.navigationFrame.selectTocItem) {
            top.navigationFrame.selectTocItem("HCView.THCView.DoSectionDrawItemPaintAfter(THCCustomData,Integer,TRect,Integer,Integer,Integer,Integer,TCanvas,TPaintInfo)");
        };

    </script>
    <script type="text/javascript">
        var tempId = "Delphi";
        $(document).ready(function() {
            $(".codeSnippetTabActive").on("click", function() {
                var obj = $(this);
                var id = obj.attr("data-lbl");
                $(".codeSnippetTabActive").removeClass("active");
                $(".codeSnippetTabActive").addClass("disActive");
                obj.removeClass("disActive");
                obj.addClass("active");
                $("#" + tempId).addClass("unActive");
                $("#" + id).removeClass("unActive");
                tempId = id;
            });
        });

    </script>
</head>

<body class="library">
    <input type="hidden" id="contentEditableControl" class="userDataStyle" value="false" />
    <input type="hidden" id="userDataCache" class="userDataStyle" />
    <input type="hidden" id="hiddenScrollOffset" />
    <input type="hidden" id="moduleName" value="HCEmrView" />
    <input type="hidden" id="elementId" value="HCView.THCView.DoSectionDrawItemPaintAfter(THCCustomData,Integer,TRect,Integer,Integer,Integer,Integer,TCanvas,TPaintInfo)" />
    <div id="content">
        <div class="topic">
            <h2 class="title">结构化病历</h2>
            <h3>前言：临床文档结构上分为四层，文档、段、数据组、数据元，描述如何实现结构化病历</h3>
            <p class="hcNor">1.临床文档<br>
                位于电子病历数据结构的最顶层，是由特定医疗服务活动（卫生事件）产生和记录的患者（或保健对象）临床诊疗和指导干预信息的数据集合。如：门（急）诊病历、住院病案首页、会诊记录等。分为两部分<br>
                （1）文档头：主要为临床文档中的各类标识信息，如文档标识、服务对象标识、服务提供者标识等。文档头可理解为临床文档的元数据，用于临床文档跨机构交换与共享时的标识、定位和管理。<br>
                （2）文档体：由文档段、数据组、数据元组成。<br>
                2.文档段<br>
                结构化的临床文档一般可拆分为若干逻辑上的段，即文档段。文档段为构成该文档段的数据提供临床语境，即为其中的数据元通用定义增加特定的约束。结构化的文档段一般由数据组组成，并通过数据组获得特定的定义。文档段的集合称为文档体。<br>
                3.数据组<br>
                由若干数据元构成，作为一个数据元集合体构成临床文档的基本单元，具有临床语义完整性和可重用性特点。数据组可以存在嵌套结构，即较大的数据组中可包含较小的子数据组。如：文档标识、主诉、用药等。<br>
                4.数据元<br>
                位于电子病历数据结构的最底层，是可以通过定义、标识、表示和允许值等一系列属性进行赋值的最小、不可再细分的数据单元。数据元的允许值由值域定义。<br><br>
                举例：<br>
                一份入院病历，包括以下信息<br>
                1.患者的人口学、医保、医生信息；<br>
                2.主诉、体格检查、病史信息；<br>
                其中，第1部分属于文档头，第2部分属于文档体，在文档体中，”主诉”、”体格检查”称为文档段，体格检查中的”生命体征”是一个数据组，生命体征中的”体温”，“血压”等是数据元。</p>
            <div id="mainSection">
                <div id="mainBody">
                    <div id="summarySection" class="section">
                        <input class="tagName" type="hidden" value="summary" />
                        <div id="summaryHeader" class="sectionHeader">
                            <div>
                                <a href="javascript:void(0)" class="collapsibleAreaHref" title="Collapse">
                                    <span class="collapsibleAreaIcon collapsibleAreaExpanding">
                                        <!---->
                                    </span>
                                    <span class="collapsibleAreaTitle">Summary</span>
                                </a>
                            </div>
                        </div>
                    </div><br />
                    <div id="syntaxSection" class="section">
                        <div id="syntaxHeader" class="sectionHeader">
                            <div>
                                <a href="javascript:void(0)" class="collapsibleAreaHref" title="Collapse">
                                    <span class="collapsibleAreaIcon collapsibleAreaExpanding">
                                        <!---->
                                    </span>
                                    <span class="collapsibleAreaTitle">数据元</span>
                                </a>
                            </div>
                        </div>
                        <div id="syntaxContent" class="sectionContent" contentEditable="false">
                            <div class="codeSnippet" contentEditable="false"><input class="code" type="hidden" value="" />
                                <div class="codeSnippetTabs tabHead">
                                    <div class="codeSnippetTabActive active" data-lbl="Delphi"><a>Delphi</a></div>
                                </div>
                                <div class="codeSnippetTabs tabHead">
                                    <div class="codeSnippetTabActive disActive" data-lbl="CSharp"><a>C#</a></div>
                                </div>
                                <div class="codeSnippetCodeContainer tabs" id="Delphi">
                                    <div class="codeSnippetCode">
                                        <h4 class="subHeading">调用InsertDeItem插入数据元，插入后可在EmrView的MouseUp事件中，通过GetTopLevelItem函数来获取到当前鼠标弹起处的数据元，进而根据数据元的不同属性，决定是否显示值域选择框或文本框。如果要显示选择框，可通过GetActiveDrawItemClientCoord方法得到当前点击处的元素相对EmrView的坐标位置，通过GetTopLevelDrawItem方法可得到当前点击在元素的哪一部分。</h4>
                                        <h4 class="subHeading">插入数据元</h4>
                                        <dl>
                                            <pre class="delphi" contentEditable="false">
procedure TfrmRecord.InsertDeItem(const AIndex, AName: string);
var
  vDeItem: TDeItem;
begin
  if (AIndex = '') or (AName = '') then
  begin
    ShowMessage('要插入的数据元索引和名称不能为空！')
    Exit;
  end;

  vDeItem := FEmrView.NewDeItem(AName);
  vDeItem[TDeProp.Index] := AIndex;
  vDeItem[TDeProp.Name] := AName;
  FEmrView.InsertDeItem(vDeItem);
end;
......
procedure TfrmRecord.DoEmrViewMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  vActiveItem: THCCustomItem;
  vDeItem: TDeItem;
  vDeGroup: TDeGroup;
  vDeEdit: TDeEdit;
  vDeCombobox: TDeCombobox;
  vDeDateTimePicker: TDeDateTimePicker;
  vDeRadioGroup: TDeRadioGroup;
  vActiveDrawItem: THCCustomDrawItem;
  vPt: TPoint;
  vDrawItemRect: TRect;
  vInfo: string;
  vTopData: THCRichData;
begin
  vInfo := '';

  vActiveItem := FEmrView.GetTopLevelItem;
  if vActiveItem <> nil then
  begin
    if FEmrView.ActiveSection.ActiveData.ActiveDomain.BeginNo >= 0 then
    begin
      vDeGroup := FEmrView.ActiveSection.ActiveData.Items[
        FEmrView.ActiveSection.ActiveData.ActiveDomain.BeginNo] as TDeGroup;

      vInfo := vDeGroup[TDeProp.Name];
    end;

    if vActiveItem is TDeItem then
    begin
      vDeItem := vActiveItem as TDeItem;
      if vDeItem.StyleEx <> cseNone  then
        vInfo := vInfo + '-' + vDeItem.GetHint
      else
      if vDeItem.Active
        and (vDeItem[TDeProp.Index] <> '')
        and (not vDeItem.IsSelectComplate)
        and (not vDeItem.IsSelectPart)
        and (CalcTickCount(FMouseDownTick, GetTickCount) < 500)  // 弹出选项对话框
      then
      begin
        if ClientCache.FindDataElementByIndex(vDeItem[TDeProp.Index]) then
          vInfo := vInfo + '-' + ClientCache.DataElementDT.FieldByName('dename').AsString + '(' + vDeItem[TDeProp.Index] + ')'
        else
          vInfo := vInfo + '-[缺少Index]';

        if FEmrView.ActiveSection.ActiveData.ReadOnly then
        begin
          sbStatus.Panels[1].Text := vInfo;
          Exit;
        end;

        vPt := FEmrView.GetActiveDrawItemClientCoord;  // 得到相对EmrView的坐标
        vActiveDrawItem := FEmrView.GetTopLevelDrawItem;
        vDrawItemRect := vActiveDrawItem.Rect;
        vDrawItemRect := Bounds(vPt.X, vPt.Y, vDrawItemRect.Width, vDrawItemRect.Height);

        if PtInRect(vDrawItemRect, Point(X, Y)) then
        begin
          vPt.Y := vPt.Y + FEmrView.ZoomIn(vActiveDrawItem.Height);
          vPt.Offset(FEmrView.Left, FEmrView.Top);
          //PopupForm.Left := vPt.X + FEmrView.Left;
          //PopupForm.Top := vPt.Y + FEmrView.Top;
          vPt := ClientToScreen(vPt);

          PopupForm.PopupDeItem(vDeItem, vPt);
        end;
      end;
    end
    else
    if vActiveItem is TDeEdit then
    begin
      vDeEdit := vActiveItem as TDeEdit;
      if ClientCache.FindDataElementByIndex(vDeEdit[TDeProp.Index]) then
        vInfo := vInfo + '-' + vDeEdit[TDeProp.Name] + '(' + vDeEdit[TDeProp.Index] + ')'
      else
        vInfo := vInfo + '-[缺少Index]';
    end
    else
    if vActiveItem is TDeCombobox then
    begin
      vDeCombobox := vActiveItem as TDeCombobox;
      if ClientCache.FindDataElementByIndex(vDeCombobox[TDeProp.Index]) then
        vInfo := vInfo + '-' + vDeCombobox[TDeProp.Name] + '(' + vDeCombobox[TDeProp.Index] + ')'
      else
        vInfo := vInfo + '-[缺少Index]';
    end
    else
    if vActiveItem is TDeDateTimePicker then
    begin
      vDeDateTimePicker := vActiveItem as TDeDateTimePicker;
      if ClientCache.FindDataElementByIndex(vDeDateTimePicker[TDeProp.Index]) then
        vInfo := vInfo + '-' + vDeDateTimePicker[TDeProp.Name] + '(' + vDeDateTimePicker[TDeProp.Index] + ')'
      else
        vInfo := vInfo + '-[缺少Index]';
    end;
  end;

  sbStatus.Panels[1].Text := vInfo;
end;
</pre>
                                        </dl>
                                    </div>
                                </div>
                                <div class="codeSnippetCodeContainer tabs unActive" id="CSharp">
                                    <div class="codeSnippetCode">
                                        <h4 class="subHeading">插入数据元</h4>
                                        <dl>
                                            <pre class="CSharp" contentEditable="false">
public void InsertDeItem(string aIndex, string aName)
{
    if ((aIndex == "") || (aName == ""))
    {
        MessageBox.Show("要插入的数据元索引和名称不能为空！");
        return;
    }
    DeItem vDeItem = FEmrView.NewDeItem(aName);
    vDeItem[DeProp.Index] = aIndex;
    vDeItem[DeProp.Name] = aName;
    FEmrView.InsertDeItem(vDeItem);
}
...
protected void DoEmrViewMouseUp(object sender, MouseEventArgs e)
{
    string vInfo = "";

    if (FEmrView.ActiveSection.ActiveData.ReadOnly)
    {
        tssDeInfo.Text = "";
        return;
    }

    HCCustomItem vActiveItem = FEmrView.GetTopLevelItem();
    if (vActiveItem != null)
    {
        if (FEmrView.ActiveSection.ActiveData.ActiveDomain.BeginNo >= 0)
        {
            DeGroup vDeGroup = FEmrView.ActiveSection.ActiveData.Items[
                FEmrView.ActiveSection.ActiveData.ActiveDomain.BeginNo] as DeGroup;

            vInfo = vDeGroup[DeProp.Name];
        }

        if (vActiveItem is DeItem)
        {
            DeItem vDeItem = vActiveItem as DeItem;
            if (vDeItem.Active
                    && (vDeItem[DeProp.Index] != "")
                    && (!vDeItem.IsSelectComplate)
                    && (!vDeItem.IsSelectPart)
                    && (Environment.TickCount - FMouseDownTick < 500)
                )
            {
                vInfo = vInfo + "元素(" + vDeItem[DeProp.Index] + ")";

                if (FEmrView.ActiveSection.ActiveData.ReadOnly)
                {
                    tssDeInfo.Text = "";
                    return;
                }

                POINT vPt = FEmrView.GetActiveDrawItemClientCoord();  // 得到相对EmrView的坐标
                HCCustomDrawItem vActiveDrawItem = FEmrView.GetTopLevelDrawItem();
                RECT vDrawItemRect = vActiveDrawItem.Rect;
                vDrawItemRect = HC.View.HC.Bounds(vPt.X, vPt.Y, vDrawItemRect.Width, vDrawItemRect.Height);

                if (HC.View.HC.PtInRect(vDrawItemRect, new POINT(e.X, e.Y)))
                {
                    vPt.Y = vPt.Y + FEmrView.ZoomIn(vActiveDrawItem.Height());
                    vPt.Offset(FEmrView.Left, FEmrView.Top);
                    HC.Win32.User.ClientToScreen(FEmrView.Handle, ref vPt);

                    PopupForm().PopupDeItem(vDeItem, vPt);
                }
            }
        }
        else
            if (vActiveItem is DeEdit)
            {

            }
            else
                if (vActiveItem is DeCombobox)
                {

                }
                else
                    if (vActiveItem is DeDateTimePicker)
                    {

                    }
    }

    tssDeInfo.Text = vInfo;
}
                                            </pre>
                                        </dl>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="seealsoSection" class="section">
                        <input class="tagName" type="hidden" value="seealso" />
                        <div id="seealsoHeader" class="sectionHeader">
                            <div>
                                <a href="javascript:void(0)" class="collapsibleAreaHref" title="Collapse">
                                    <span class="collapsibleAreaIcon collapsibleAreaExpanding">
                                        <!---->
                                    </span>
                                    <span class="collapsibleAreaTitle">查看</span>
                                </a>
                            </div>
                        </div>
                        <div id="seealsoContent" class="sectionContent" contentEditable="false">
                            <ul class="seeAlsoCodeReference">
                                <li><a href="HCEmrView_Property.htm" title="HCEmrView属性">HCEmrView属性</a></li>
                                <li><a href="HCEmrView_Method.htm" title="HCEmrView方法">HCEmrView方法</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="footer">
        <div id="footerContent"></div>
    </div>
</body>

</html>
